package com.example.demo.controller;

import com.example.demo.polo.News;
import com.example.demo.polo.Result;
import com.example.demo.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class NewsController {
    @Autowired
    NewsService newsService;
    @PostMapping("/app5/news/list")
    public Result getAllList(){
        List<News> list=newsService.getAllNews();
        Result r=new Result();
        if (list!=null){
            r.setMsg("成功");
            r.setSuccess(true);
            r.setList(list);
        }else {
            r.setMsg("失败");
            r.setSuccess(false);

        }
        return r;

    }

}
